{% extends 'index.html' %}

{% block title %}
    <title>图书录入</title>
{% endblock %}

{% block con %}
<div class="row">
    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
        <div class="widget am-cf">
            <div class="widget-head am-cf">
                <div class="widget-title am-fl">图书录入</div>
                <div class="widget-function am-fr">
                    <a href="javascript:;" class="am-icon-cog"></a>
                </div>
            </div>
            <div class="widget-body am-fr">

                <form action="{{ url_for('admin.books_add')}}" method="POST"  enctype="multipart/form-data" class="am-form tpl-form-line-form">
                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            书名
                        </label>
                        <div class="am-u-sm-9">
                            <input name="title" required type="text" class="tpl-form-input">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            作者
                        </label>
                        <div class="am-u-sm-9">
                            <input name="author" required type="text" class="tpl-form-input">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            出版社
                        </label>
                        <div class="am-u-sm-9">
                            <input name="publisher" required type="text" class="tpl-form-input">
                        </div>
                    </div>


                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            价格
                        </label>
                        <div class="am-u-sm-9">
                            <input name="price" required type="text" class="tpl-form-input">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            书号
                        </label>
                        <div class="am-u-sm-9">
                            <input name="isbn13" required maxlength="13" minlength="13" type="text" class="tpl-form-input">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="user-weibo" class="am-u-sm-3 am-form-label">
                            封面图 
                        </label>
                    <div class="am-u-sm-9">
                      <div class="am-form-group am-form-file">
                          <div class="tpl-form-file-img">
                              <img id="showImg" style="width: 200px;" src="assets/img/a5.png" alt="">
                          </div>
                          <button type="button" class="am-btn am-btn-danger am-btn-sm">
                            <i class="am-icon-cloud-upload"></i> 添加封面图片</button>
                          <input id="ReadFile" name="pic" type="file" multiple="">
                      </div>
                    </div>
                    </div>
                    <script type="text/javascript">
                        $('#ReadFile').change(function(){
                            var file = this.files[0];

                            //限定上传文件的类型，判断是否是图片类型
                            if (!/image\/\w+/.test(file.type)) {
                                alert("只能选择图片");
                                return false;
                            }
                            var reader = new FileReader();
                            reader.readAsDataURL(file);
                            reader.onload = function(e) {
                                base64Code = this.result;
                                //把得到的base64赋值到img标签显示
                                $("#showImg").attr("src", base64Code);
                            }
                        })
                    </script>
                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            内容推荐
                        </label>
                        <div class="am-u-sm-9">
                            <textarea  rows="5" name="summary" placeholder="请输入文章简介"></textarea>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            作者简介
                        </label>
                        <div class="am-u-sm-9">
                            <textarea rows="5" name="author_intro" placeholder="请输入作者简介"></textarea>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            目录
                        </label>
                        <div class="am-u-sm-9">
                            <textarea rows="5" name="catalog" placeholder="请输入目录"></textarea>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            出版日期
                        </label>
                        <div class="am-u-sm-9">
                            <input name="pubdate" type="month" class="tpl-form-input">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            数量
                        </label>
                        <div class="am-u-sm-9">
                            <input name="num" type="text" class="tpl-form-input">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="user-name" class="am-u-sm-3 am-form-label">
                            状态
                        </label>
                        <div class="am-u-sm-9">
                            <select name="status" data-am-selected="{searchBox: 1}" style="display: none;">
                                <option value="0">立即上架</option>
                                <option value="1">录入书库</option>
                            </select>
                        </div>
                    </div>

                      
                    <div class="am-form-group">
                        <div class="am-u-sm-9 am-u-sm-push-3">
                            <button class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{% endblock %}